package com.amat0urheu.controller.studentController;

import com.amat0urheu.pojo.ReturnRes;
import com.amat0urheu.service.ExperimentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/apiaaW")
public class ExperimentController2 {
    final ExperimentService experimentService;

    @Autowired
    public ExperimentController2(ExperimentService experimentService) {
        this.experimentService = experimentService;
    }


    @GetMapping("/experiment/{pageSize}/{pageNum}")
    public ReturnRes getExperimentpage(@PathVariable int pageSize, @PathVariable int pageNum) {
        return  experimentService.getExperimentpage(pageSize,pageNum);
    }

    @GetMapping("/user/experiment/{eid}")
    public ReturnRes getExperimentByIdForUser(@PathVariable String  eid) {


        return experimentService.getExperimentByIdForUser(eid);
    }

    @GetMapping("/user/experiment/apply/{eid}")
    public ReturnRes applyExperimentForUser(@PathVariable String eid, Authentication authentication) {
//        experimentService.setLineUP(eid,authentication.getName());//mc_container_array 数据库

        return experimentService.getExperimentByIdForUser(eid);
    }

}
